#include <shared_mutex>
// mutex example
#include <iostream> // std::cout
#include <thread>   // std::thread
#include <mutex>    // std::mutex

std::mutex mtx; // mutex for critical section

int test_int = 0;

int  read_int;
void read_()
{
    for (int i = 0; i < 100; ++i)
    {
        std::cout << test_int << std::endl;
        std::this_thread::sleep_for(std::chrono::milliseconds(10));
    }
}
void write_()
{
    for (int i = 0; i < 100; ++i)
    {
        test_int++;
        std::this_thread::sleep_for(std::chrono::milliseconds(10));
    }
}

int main()
{
    std::thread th1(read_);
    std::thread th2(write_);

    th1.join();
    th2.join();

    return 0;
}